package com.wjs.juc.volatiles;

import java.util.concurrent.CountDownLatch;

public class MyTest {
    static volatile int i=0;
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch=new CountDownLatch(100);
        for (int i1 = 1; i1 <= 100; i1++) {
            new Thread(()->{

                try {
                    for (int i2 = 0; i2 < 1000; i2++) {
                        i++;
                    }
                } finally {
                    countDownLatch.countDown();
                }
            },"T"+i1).start();
        }
        countDownLatch.await();
        System.out.println(i);
    }
}
